﻿using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using Garfield.Controls;
using Garfield.Presentation.Controls;
using Garfield.Presentation.View;

namespace ViewSites
{
    /// <summary>
    /// Interaction logic for ControlPanel.xaml
    /// </summary>
    public partial class LaunchBar
    {
        private readonly INavigator navigator;

        public LaunchBar(INavigator navigator)
        {
            this.navigator = navigator;
            InitializeComponent();
            selector.SuggestionProvider = new TreeSuggestionProvider();
        }

        private void LauchHelloWorldToRootView(object sender, RoutedEventArgs e)
        {
            navigator.NavigateToView("HelloWorld", null);
        }
    }

    class SuggestionProvider : ISuggestionProvider
    {
        private readonly string[] suggestions = new[] { "abc", "abc1", "abc2", "abc3", "abc4", "abc5", "abc6", "abc7", "abc8", "abc9", "abc10", "abc11", "abc12", "abc13", "abc14", "abc15", "def" };

        public IEnumerable GetSuggestions(string keyword)
        {
            return keyword == string.Empty ? new string[0] : suggestions.Where(suggestion => suggestion.Contains(keyword));
        }
    }

    class TreeSuggestionProvider : ISuggestionProvider
    {
        private readonly TreeNode[] suggestions = new[] { new TreeNode { Description = "Root", Children = new List<TreeNode> { new TreeNode { Description = "Node 1" } } } };

        public IEnumerable GetSuggestions(string keyword)
        {
            return suggestions;
        }
    }

    class TreeNode
    {
        public string Description { get; set; }
        public IList<TreeNode> Children { get; set; }

        public TreeNode()
        {
            Children = new List<TreeNode>();
        }
    }

}
